package com.zhixiang.xaec.action.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zhixiang.core.command.QueryFilter;
import com.zhixiang.core.web.action.BaseAction;
import com.zhixiang.xaec.entity.system.StoreRoom;
import com.zhixiang.xaec.service.system.StoreRoomService;
@Controller
@Scope("prototype")
public class StoreRoomAction extends BaseAction
{

    private static final long serialVersionUID = -7187764737502691044L;
    
    private StoreRoom storeRoom;
    
    @Autowired
    StoreRoomService storeRoomservice;
    
    
    public StoreRoom getStoreRoom()
    {
        return storeRoom;
    }

    public void setStoreRoom(StoreRoom storeRoom)
    {
        this.storeRoom = storeRoom;
    }

    public String list(){
        QueryFilter localQueryFilter = new QueryFilter(getRequest());
        List<StoreRoom>localList = this.storeRoomservice.getAll(localQueryFilter);         
        setSuccess(true);
        setTotalCounts(localQueryFilter.getPagingBean().getTotalItems());
        //返回结果集
        setResult(localList);
        return SUCCESS;
    }
    
    public String delete(){
        try
        {
            String[] ids = getRequest().getParameterValues("ids");
            storeRoomservice.delete(ids);      
            return SUCCESS;
        }
        catch (Exception e)
        {
            setSuccess(false);
            setMsg("库房正被使用无法删除！");
            return SUCCESS;
        }

    }
    
    public String get(){
        String id = getRequest().getParameter("id");
        if(!"".equals(id)&&id!=null){
            setResult(storeRoomservice.get(Long.valueOf(id))); 
        }             
        return SUCCESS;
    }
    
    public String save(){
        storeRoomservice.save(storeRoom);
        return SUCCESS;
    }

}
